<?php
use yii\helpers\Html ;
use backend\models\AdminUser ;
$id = Yii::$app->request->get("id",0) ;
$user_id = Yii::$app->request->get("user_id",0) ;
$time = Yii::$app->request->get("time",0) ;
$user = AdminUser::findOne(["user_id"=>$user_id]) ;
?>
<div class="wrap">
    <div class="title">人员评价</div>
    <form id="form" method="post" action="<?= \yii\helpers\Url::to(["/site/add-evalu","id"=>$id,"user_id"=>$user_id,"time"=>$time])?>">
    <div class="evaluate">
        <div class="item">
            <div class="ti" style="text-align: center">
                <?=empty($user->username)?"":$user->username?>
            </div>
            <?php if(!empty($user->avatar)):?>
            <div class="ti" style="text-align: center">
                <img src="<?=$user->avatar?>" width="100px">
            </div>
            <?php endif;?>
        </div>


        <?php $arr=[] ;?>
        <?php foreach($list as $val):?>
        <div class="item">
            <?php $arr[] = $val['id']?>
            <div class="ti">
                <?=$val['title'] ;?>
            </div>
            <?php foreach($val['contentArr'] as $content):?>
            <p>
                <input type="radio" value="<?=$content?>" name="select<?=$val['id'] ;?>" />
                <label><?=$content?></label>
            </p>
            <?php endforeach;?>
        </div>
        <?php endforeach;?>
        <?= Html::hiddenInput('_csrf_mobile',\Yii::$app->getRequest()->csrfToken) ?>
        <?php foreach($list as $val):?>
        <?= Html::hiddenInput('idArr[]',$val['id']) ?>
        <?= Html::hiddenInput('title'.$val['id'],$val['title']) ?>
        <?php endforeach;?>
        <input type="submit" class="submit" onclick="showLoading()" value="提交" />
    </div>
    </form>
</div>
<div class="loading"></div>
<div class="dialogue">
    <div class="content">
        <p>感谢您的评价!</p>
        <button onclick="hideDialogue(true)">关闭</button>
    </div>
</div>
<script type="text/javascript">
    let showLoading = function(){
        $('.loading').css('display', 'flex')
    }
    let showDialogue = function(){
        $('.dialogue').css('display', 'flex')
    }
    let hideLoading = function(){
        $('.loading').hide()
    }
    let hideDialogue = function(close){ //close为ture就关闭页面
        $('.dialogue').hide()
        if(close){
            closePage()
        }
    }
    let closePage = function(){
        try{
            window.close()
        }
        catch(e){}
        try{
            WeixinJSBridge.call('closeWindow');
        }
        catch(e){}
    }
</script>